home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Help / Shells < prev    next >
Encoding:
Text File  |  2000-12-27  |  11.2 KB  |  336 lines

  1.  
  2. Shells
  3.  
  4.                                                version: 1.1
  5.                                                created: 00-08-23 16.56.59
  6.                                            last update: 00-12-27 23.45.03
  7.  
  8.  
  9. This file documents the Tcl shell and the Toolserver shell.
  10.  
  11.  
  12.           Tcl Shell
  13.  
  14.  
  15. The basic idea of the Tcl Shell is to provide an interactive way to access
  16. TCL, it is *NOT* intended to serve as a pseudo-unix-shell.  However, I
  17. don't use MPW or AU/X, and therefore I implemented a few very useful unix
  18. shell functions.
  19.  
  20. All pathnames must be mac pathnames; relative pathnames start with colons,
  21. absolute pathnames don't.  For instance, ':file1' specifies a file named
  22. 'file1' in the current directory.  '::file2' specfies a file in the parent
  23. directory, and ':::file3' is a file in the parent's parent's directory. 
  24. Additionally, hitting command-tab with a partial pathname invokes a
  25. filename-completion function that tries to fill in the rest of the
  26. characters of the name.
  27.  
  28. The supported functions are all valid Tcl commands and the following:
  29.  
  30.     cat <file>...  
  31.  
  32. Dump contents of files into shell window.
  33.  
  34.     cd <relative or absolute pathname>
  35.  
  36.     Change directory. If called with no arguments, go to home directory.
  37.  
  38.     cp <file1> <file2>          or
  39.     cp <file1> .... <destDir>
  40.  
  41. Basic unix functionality, recursive.
  42.  
  43.     dirs
  44.  
  45. show current directory stack. See 'pushd' and 'popd'.
  46.  
  47.     grep <pat> <file>...
  48.  
  49. Grep, reasonably slow.
  50.  
  51.     mkdir <dirname>
  52.  
  53. make a directory (folder)
  54.  
  55.     ls [-F|l] [<file>]...
  56.  
  57. Two, mutually exclusive flags.  '-F' just gives the normal display, with a
  58. '*' behind applications and a '/' behind directories (folders).  '-l'
  59. presents a long listing, including sizes of both forks, creator, file type,
  60. and last modification time.  'procs.tcl' includes functions 'l' and 'll'
  61. which serve as my Unix aliases to 'ls -F' and 'ls -l'.
  62.     
  63.     mv <file1> <file2>          or
  64.     mv <file1> .... <destDir>
  65.     
  66. Moves a file, potentially across volume boundaries. Recursive.
  67.  
  68.     popd
  69.  
  70. Pop top dir off dir stack and 'cd' to it.
  71.  
  72.     pushd [<dir>]
  73.  
  74. If 'dir' specified, push current folder into directory stack and 'cd' to
  75. dir.  Otherwise, swap current dir w/ top of dir stack.
  76.  
  77.     ps
  78.  
  79. Prints a list of active applications.
  80.     
  81.     rm [-r] <file>...
  82.  
  83. Removes files and empty directories. "-r" allows recursive removal, but 
  84.  
  85. DON'T BLAME ME IF YOU DELETE YOUR ENTIRE DRIVE!    
  86.  
  87.     rmdir <dirname>
  88.  
  89. remove a directory (folder)
  90.  
  91.     setCreator <creator> <files>
  92.  
  93. Changes the creator of given files, which can be glob expressions.
  94.  
  95.     setType <type> <files>
  96.  
  97. Changes the type of given files, which can be glob expressions.
  98.  
  99.     wc <file>...
  100.  
  101. 'wc' primitive from unix, counts lines, words, characters.
  102.  
  103.  
  104. The file "shellMode.tcl" contains Tcl code implementing the shell
  105. interface.  You can change this to suit your tastes.  One recent goody is
  106. that you can re-execute previous commands merely by moving the cursor to
  107. the line and hitting the return key.  If there is no '>' character on the
  108. line when you hit a carriage return, the return is an ordinary new line.
  109.  
  110. A primitive history mechanism can be used to move up and down the last 20 
  111. commands by using control-uparrow and control-downarrow at a prompt.
  112.  
  113.           
  114.     ======================================================================
  115.  
  116.  
  117.           Using ToolServer With Alpha
  118.  
  119.  
  120. Draft, March 16, 1999: Eric Petersen <epeterse@aem.umn.edu>
  121.  
  122.  
  123.                Introduction
  124.  
  125.  
  126. ToolServer is a complete tool and script execution environment extracted
  127. from the MPW Shell that you can use to execute time-consuming,
  128. noninteractive tools or scripts in the background or on a remote machine. 
  129. Thus ToolServer can run most of the tools and scripts in the MPW tool suite
  130. and most tools and scripts which are written for MPW. The major exceptions
  131. are editor and Projector commands.
  132.  
  133. ToolServer is primarily designed to be run using Apple events.  As such, it
  134. can be run from MPW 3.3 or later using the built-in MPW RShell command and
  135. from third-party applications that include support for ToolServer.  You can
  136. also use ToolServer as a foreground application; you specify the scripts to
  137. be executed and obtain the status of executing scripts by choosing the
  138. appropriate File menu items.
  139.  
  140. [From “ToolServer Reference”]
  141.  
  142.                Getting Started
  143.  
  144. Type control-command-Y to open the Toolserver Shell, an Alpha window titled
  145. “*Toolserver shell*”.  (This will also launch the ToolServer
  146. application.)  You will see the following message and prompt:
  147.  
  148.     Welcome to Alpha's MPW shell (using ToolServer via AppleEvents).
  149.     «mpw» |
  150.  
  151. The cursor will be positioned as shown by the “|”.  You may now type a
  152. command and hit _return_ (MPW users will have to unlearn hitting _enter_ to
  153. execute a command).  The following commands are supported by ToolServer:
  154.  
  155.     Alert          Directory      Exit           Newer          Shift
  156.     Alias          Duplicate      Export         NewFolder      ShutDown
  157.     Beep           Echo           Files          Parameters     Unalias
  158.     Begin...End    Eject          Flush          Quit           Unexport
  159.     Break          Else           For...         Quote          Unmount
  160.     Catenate       Equal          Help           Rename         Unset
  161.     Confirm        Erase          If...          Request        Version
  162.     Continue       Evaluate       Loop...End     RShell         Volumes
  163.     Date           Execute        Move           Set            Which
  164.     Delete         Exist          Mount          SetFile
  165.  
  166. Additional tools and scripts may be placed in the “Scripts”, “Tools”, and
  167. “User Commands” folders.  These names are for your benefit only; tools may
  168. be placed in the “Scripts” folder, user-defined commands may be placed in
  169. the “Tools” folder, etc.  You should be aware that newer distributions of
  170. MPW have merged the “Tools” and “Scripts” folders into a single “Commands”
  171. folder.  ToolServer also has access to environment variables, called MPW
  172. variables.  The _value_ of these variables is obtained by enclosing the
  173. variable name in curly braces.  For example, the command [1]
  174.  
  175.     «mpw» echo {commands}
  176.  
  177. will return a comma-delimited list of the pathnames that ToolServer
  178. searches to find commands:
  179.  
  180.     :,HD:MPW:User Commands:,HD:MPW:Tools:,HD:MPW:Scripts:
  181.  
  182. Thus the current directory “:” is searched first, then “User Commands”,
  183. “Tools”, and “Scripts” in that order.
  184.  
  185. * [1] You should be aware that MPW and ToolServer are not, by default, case
  186. sensitive.
  187.  
  188. If you wish to save typing keystrokes---and time spent learning---by using
  189. Unix-style command names, you may execute commands such as
  190.  
  191.     «mpw» alias cd     directory
  192.     «mpw» alias pwd    directory
  193.     «mpw» alias grep   search
  194.     «mpw» alias mkdir  newfolder
  195.     «mpw» alias mv     move
  196.     «mpw» alias cp     duplicate
  197.     «mpw» alias rm     delete
  198.     «mpw» alias ls     files
  199.     «mpw» alias source execute
  200.  
  201. These aliases will be forgotten when ToolServer quits however.  It would be
  202. better to save these commands in a file in the “TS Startup Items” folder;
  203. all files in “TS Startup Items” are executed when ToolServer launches.  The
  204. items in the “TS Startup Items” folder do not have any special naming
  205. conventions, and will be executed in alphabetical order.  They can also be
  206. any type of executable entity, such as scripts, tools, and/or applications. 
  207. As we'll see later on, you might want to put an alias of the Key Caps
  208. utility in as well.
  209.  
  210. To get started, make an alias of the Alpha application and place it in the
  211. “User Commands” folder.  Now the command (assuming that the alias is named
  212. “alpha”)
  213.  
  214.     «mpw» alpha foo
  215.  
  216. will open the file “foo” in the current directory with Alpha.  This is of
  217. little use until the current directory is set; the current directory is set
  218. to the location of the ToolServer application initially.  Obviously the
  219. “directory” command is needed here, but how does it work?  Type
  220.  
  221.     «mpw» help directory
  222.  
  223. to get the help text
  224.  
  225.     Directory       # set or write the default directory
  226.     Directory [-q | directory]  > directory
  227.         -q          # don't quote directories with special characters
  228.  
  229. “Directory” by itself writes the full pathname of the current directory
  230. (hence the alias to “pwd” above), while “directory dir_pathname” sets the
  231. current directory to “dir_pathname” (as would be expected from the alias to
  232. “cd”).  To see an example, try
  233.  
  234.     «mpw» directory
  235.     «mpw» directory :: ; directory
  236.  
  237. which return “HD:MPW:” and “HD:”, respectively, in this example.  (The
  238. parent directory of “:” is “::”, “:::” is the grandparent directory, etc. 
  239. We also note the use of “;” to separate commands on a line.)  Now “files”
  240. will list the files _and_ folders in the current directory:
  241.  
  242.     «mpw» files
  243.     :Applications:
  244.     ':Desktop Folder:'
  245.     :MPW:
  246.     :Papers:
  247.     :Pictures:
  248.     :Trash:
  249.     Bookmarks.html
  250.     cholesky.tex
  251.     thesispage.sty
  252.  
  253. Note that names with spaces or special characters must be quoted if they
  254. are to be used in commands.  You can now navigate to your desired folder
  255. all at once, or step-by-step:
  256.  
  257.     «mpw» directory 'HD:Applications:Alpha ƒ:Tcl:Modes:'
  258.  
  259. In this example, the “ƒ” (option-f) character was entered via the menu item
  260. "Utils -> Ascii Etc -> Insert Ascii", since _typing_ option-f will trigger
  261. the "Edit -> Emacs -> Forward Word" command in Alpha.  (Its ASCII code is
  262. decimal 196.  You could also paste it from, say, the Key Caps utility.) 
  263. Now, to find all occurrances of the string “ToolServer” in the code, type
  264.  
  265.     «mpw» search -i toolserver ≈.tcl  # -i is a case-insensitive search
  266.  
  267. The MPW wildcard character “≈” (option-x) is ASCII code 197, and the “#”
  268. symbol starts a comment.
  269.  
  270. As a final exercise, let's create a small, but useless, script to play a
  271. tune.  We'll need the “beep” command, so let's find out how to use it.
  272.  
  273.     «mpw» help beep
  274.     Beep            # generate tones
  275.     Beep [note [,duration [,level]]]…
  276.         #   duration is given in sixtieths of a second (default is 15)
  277.         #   sound level is given as a number from 0 to 255 (default is 128)
  278.  
  279. So save the following pair of lines in a new file “Chimes” in the “User
  280. Commands” folder:
  281.  
  282.     beep 2e,20,40  2c,20,60  2d,20,80  1g,40,100
  283.     beep 1g,20,120 2d,20,140 2e,20,160 2c,40,180
  284.  
  285. When the file is saved, type
  286.  
  287.     «mpw» chimes
  288.  
  289. to hear the tune.
  290.  
  291.  
  292.                Miscellany
  293.  
  294.  
  295. • You should also note that ToolServer will not automatically come to the
  296. front when an interactive command, such as Alert, is executed.
  297.  
  298.  
  299.         Where to Download
  300.  
  301. • ToolServer
  302.  
  303. <ftp://ftp.apple.com/devworld/Tool_Chest/Core_Mac_OS_Tools/MPW_etc./MPW-GM/MPW/ToolServer.sit.hqx>
  304.  
  305. • ToolServer Reference (PDF format)
  306.  
  307. <ftp://ftp.apple.com/devworld/Tool_Chest/Core_Mac_OS_Tools/MPW_etc./Documentation/MPW_Reference/ToolServer_Reference.sit.hqx>
  308.  
  309. • Introduction to MPW (PDF format)
  310.  
  311. <ftp://ftp.apple.com/devworld/Tool_Chest/Core_Mac_OS_Tools/MPW_etc./Documentation/MPW_Reference/Introduction_to_MPW.sit.hqx>
  312.  
  313. • MPW Tools for use with ToolServer
  314.  
  315. <ftp://ftp.apple.com/devworld/Tool_Chest/Core_Mac_OS_Tools/MPW_etc./MPW-GM/MPW/Tools/>
  316.  
  317. • MPW Command Reference (documentation for MPW Tools, PDF format)
  318.  
  319. <ftp://ftp.apple.com/devworld/Tool_Chest/Core_Mac_OS_Tools/MPW_etc./Documentation/MPW_Reference/MPW_Command_Reference.sit.hqx>
  320.  
  321.  
  322.           FAQ
  323.  
  324. • Q: My file in “TS Startup Items” doesn't get executed.  Why not?
  325.  
  326. • A: You probably have a syntax error or are trying to use a command not
  327. supported by ToolServer.  Look in the file “StartupTS.err” in the directory
  328. with ToolServer.  It will probably contain something like
  329.  
  330.     ### ToolServer - Execution of HD:MPW:TS Startup Items:your_file terminated.
  331.     ### ToolServer - Execution of StartupTS terminated.
  332.  
  333. Unfortunately, you have to figure out the offending command or syntax on
  334. your own.
  335.  
  336.